package org.sy.lab.Java7并发编程实战.二线程同步基础.五使用读写锁实现同步数据访问;

public class Writer implements Runnable {
	private PricesInfo pricesInfo;
	public Writer(PricesInfo pricesInfo) {
		this.pricesInfo = pricesInfo;
	}
	@Override
	public void run() {
		for(int i=0; i<3; i++) {
			System.out.printf("Writer: Attempt to modify the prices.\n");
			pricesInfo.setPrices(Math.random() * 10, Math.random()*8);
			System.out.printf("Writer: prices have been modified.\n");
			try {
				Thread.sleep(2);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
